<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<ul>
    <li>右键菜单项1</li>
    <li>右键菜单项2</li>
    <li>右键菜单项3</li>
</ul>
<script>
    let ulObj = document.getElementsByTagName('ul')[0];
    ulObj.style.border = 'solid 1px #666';
    ulObj.style.width = '100px';
    ulObj.style.position = 'absolute';
    ulObj.style.display = 'none';
    document.oncontextmenu = function(event){
        ulObj.style.display = 'block';
        ulObj.style.left = event.clientX+'px';
        ulObj.style.top = event.clientY+'px';
        event.preventDefault();
    }
    ulObj.onclick = function(){
        this.style.display = 'none';
    }
</script>
</body>
</html>